//
//  BPUserInfoViewController.swift
//  BP_NewClient
//
//  Created by letv on 15/6/18.
//  Copyright (c) 2015年 normal. All rights reserved.
//  修改用户信息

import UIKit

class BPUserInfoViewController: BPRootViewController {

    @IBOutlet var myTableView : UITableView?
    
    var dataArray : [String] = ["修改用户名","修改密码","积分兑换","地址信息"]
    let cellIdentifier = "BPUserInfoTableViewCell"

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.navigationItem.title = "我的账户"
        self.navigationItem.leftBarButtonItem = self.getBackNavigationItem()
        
        myTableView!.registerNib(UINib(nibName: "BPUserInfoTableViewCell", bundle:nil), forCellReuseIdentifier: cellIdentifier)
    }
    
    // MARK: - Table view data source
    //返回节的个数
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    //返回某个节中的行数
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.dataArray.count
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
    {
        return 50
    }
    
    //为表视图单元格提供数据，该方法是必须实现的方法
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let mycell : BPUserInfoTableViewCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! BPUserInfoTableViewCell

        mycell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
        mycell.selectionStyle = UITableViewCellSelectionStyle.None
        var row = indexPath.row
        let rowName : String = self.dataArray[indexPath.row]
        mycell.name?.text = rowName;
    
        return mycell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        let row = indexPath.row
        
        // 0-修改用户名 1.修改密码 2.地址管理
        if (row == 0){
            let modifyUserName : BPModifyNameViewController = BPModifyNameViewController(nibName: "BPModifyNameViewController", bundle: nil)
            self.navigationController?.pushViewController(modifyUserName, animated: true)
        }else if (row == 1){
            let modifyPwd : BPModifyPwdViewController = BPModifyPwdViewController(nibName: "BPModifyPwdViewController", bundle:nil)
            self.navigationController?.pushViewController(modifyPwd, animated: true)
        }else if (row == 2){

        
        }else{
        
            
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
